a tool for shared writing and social publishing
at feature/thread-viewer 50 lines 1.5 kB view raw
1import { makeRouter } from "../lib"; 2import { push } from "./push"; 3import { createClient } from "@supabase/supabase-js"; 4import { Database } from "supabase/database.types"; 5import { pull } from "./pull"; 6import { getFactsFromHomeLeaflets } from "./getFactsFromHomeLeaflets"; 7import { Vercel } from "@vercel/sdk"; 8import { 9 get_domain_status, 10 get_leaflet_subdomain_status, 11} from "./domain_routes"; 12import { get_leaflet_data } from "./get_leaflet_data"; 13import { get_publication_data } from "./get_publication_data"; 14import { search_publication_names } from "./search_publication_names"; 15import { search_publication_documents } from "./search_publication_documents"; 16 17let supabase = createClient<Database>( 18 process.env.NEXT_PUBLIC_SUPABASE_API_URL as string, 19 process.env.SUPABASE_SERVICE_ROLE_KEY as string, 20); 21 22const VERCEL_TOKEN = process.env.VERCEL_TOKEN; 23const vercel = new Vercel({ 24 bearerToken: VERCEL_TOKEN, 25}); 26const Env = { 27 supabase, 28 vercel, 29}; 30export type Env = typeof Env; 31export type Routes = typeof Routes; 32let Routes = [ 33 push, 34 pull, 35 getFactsFromHomeLeaflets, 36 get_domain_status, 37 get_leaflet_subdomain_status, 38 get_leaflet_data, 39 get_publication_data, 40 search_publication_names, 41 search_publication_documents, 42]; 43export async function POST( 44 req: Request, 45 { params }: { params: Promise<{ command: string }> }, 46) { 47 let p = await params; 48 let router = makeRouter(Routes); 49 return router(p.command, req, Env); 50}